package io.github.yotta.common.api.model;

import io.github.yotta.common.api.exception.BaseErrorCode;
import io.github.yotta.common.utils.param.ParamUtil;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author yotta
 * @date 2022/11/7 18:15
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ApiPageRequest extends ApiRequest {


    private Integer pageNo = 1;

    private Integer pageSize = 20;

    @Override
    public void checkValid() {
        super.checkValid();
        ParamUtil.expectFalse(this.pageNo <= 0, BaseErrorCode.PAGE_PARAM_IS_INVALID.getCode());
        ParamUtil.expectFalse(this.pageSize <= 0, BaseErrorCode.PAGE_PARAM_IS_INVALID.getCode());
    }
}
